package com.example.springboot.demo.controller;

import me.ahoo.cosid.segment.SegmentId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/segment")
public class SegmentIdController {

    @Qualifier("__share__SegmentId")
    @Lazy
    @Autowired
    private SegmentId segmentId;

    @GetMapping("/id3")
    public Object id3() {
        long id = segmentId.generate();
        return id;
    }


    @GetMapping("/stat")
    public Object stat() {
        return segmentId.stat();
    }

}
